package rentadomus

class HouseController {

    //def index() { }
    def scaffold = House
    def save() {
        def houseInstance = new House(params)
        def dwellingInstance = new Dwelling(params)
        def placeInstance = new Place(params)
        placeInstance.idPerson = session.person
        houseInstance.idDwelling = dwellingInstance
        dwellingInstance.idPlace= placeInstance
        if (placeInstance.save(flush: true)) {
            if(dwellingInstance.save(flush: true)){
                if (!houseInstance.save(flush: true)) {
                    render(view: "create", model: [houseInstance: houseInstance])
                    return
                }
            }
        }
        redirect(controller:"uploadImage", action: "main", id: placeInstance.id)
    }
}
